package com.rytong.tools.ui.chart;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.widget.AbsoluteLayout;

import com.rytong.tools.ui.Component;
import com.rytong.tools.ui.CssStyle;
import com.rytong.tools.utils.Utils;

public class LPPlotTipsLayout extends Component{

    //背景图片
    Bitmap bgImage_;
    
    public class MyLPPlotTipsLayout extends AbsoluteLayout implements CompositedComponent{

        public MyLPPlotTipsLayout(Context context,String value) {
            super(context);
        }

        @Override
        public Component composited() {
            return LPPlotTipsLayout.this;
        }
        
    }

    @Override
    public void initRealView(Activity activity, String nodeValue) {
        super.initRealView(activity, nodeValue);
        realView_ = new MyLPPlotTipsLayout(activity,nodeValue);
    }

    @Override
    public void mouldH() throws Exception {
        // TODO Auto-generated method stub
        super.mouldH();
        cssStyle_ = this.cssStyle();
        String bgImageUrl = (String) cssStyle_.getProperty(CssStyle.BGIMAGEURL);
        if (null != bgImageUrl && !bgImageUrl.equals("")) {
            // 根据样式定义控件选中图片
            bgImage_ = Utils.getBitmapFromResources(getContext(), bgImageUrl);
            if (null != bgImage_) {
                realView_.setBackgroundDrawable(new BitmapDrawable(bgImage_));
            }
        }
    }
    
    @Override
    public void releaseResource(Component component) {
    	super.releaseResource(component);
    	if(bgImage_ != null && !bgImage_.isRecycled()){
    		bgImage_.recycle();
    		bgImage_ = null;
    	}
    }
}
